\documentclass{article}
\usepackage{listings}

\begin{document}

\section{Introduction}

Here is some sample code:

\begin{lstlisting}[language=Python, numbers=left]
def hello_world():
    print("Hello, world!")
\end{lstlisting}

Here is an example how to write \(q \leq \delta \) and \(q \in Q\) in
a code block:

\begin{lstlisting}[mathescape=true, numbers=left]
  Assume q $\leq$ $\delta$ and q $\in$ Q
\end{lstlisting}

Thanks!

\end{document}
\end{document}
